package com.talent.web.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.talent.web.excel.model.DataDemo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName：SimpleReadListener
 * @Author: hszhou
 * @Date: 2024/11/16 13:06
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class SimpleReadListener implements ReadListener<DataDemo> {

    protected  final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void invoke(DataDemo dataDemo, AnalysisContext analysisContext) {
        //读取到每一行数据
        logger.info("读取数据{}",dataDemo);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        //一个sheet数据解析完毕

        logger.info("数据读取完毕");
    }

    @Override
    public void onException(Exception exception, AnalysisContext context) throws Exception {
        ReadListener.super.onException(exception, context);
        //处理异常信息
    }

}
